home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SNNSV32.ZIP / SNNSv3.2 / kernel / sources / matrix.h < prev    next >
C/C++ Source or Header  |  1994-04-25  |  6KB  |  160 lines

  1. /*****************************************************************************
  2.   FILE           : matrix.h
  3.   SHORTNAME      : 
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        : SNNS-Kernel standard matrix operations
  7.   NOTES          :
  8.  
  9.   AUTHOR         : Michael Vogt
  10.   DATE           : 10.02.92
  11.  
  12.   CHANGED BY     : Sven Doering
  13.   IDENTIFICATION : @(#)matrix.h    1.10 3/15/94
  14.   SCCS VERSION   : 1.10
  15.   LAST CHANGE    : 3/15/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.  
  19. ******************************************************************************/
  20.  
  21. #ifndef    _RBF_MATRIX_DEFINED_
  22. #define _RBF_MATRIX_DEFINED_
  23.  
  24.  
  25. /************************************************************************/
  26. /* type definitions:                            */
  27. /************************************************************************/
  28.  
  29. typedef struct
  30. {
  31.     int    rows;        /* number of rows            */
  32.     int    columns;    /* number of columns            */
  33.     float    *field;        /* matrix organized as list        */
  34.     float    **r_pt;        /* array of references to rows        */
  35. } RbfFloatMatrix;
  36.  
  37. /************************************************************************/
  38. /* allocate matrix m with r rows and c columns                */
  39. /* returns 0 if impossible, 1 otherwise                    */
  40. /************************************************************************/
  41.  
  42. extern int    RbfAllocMatrix(int r, int c, RbfFloatMatrix *m);
  43.  
  44. /************************************************************************/
  45. /* deallocate matrix m                            */
  46. /************************************************************************/
  47.  
  48. extern void    RbfFreeMatrix(RbfFloatMatrix *m);
  49.  
  50. /************************************************************************/
  51. /* set all elements of matrix m to value c                */
  52. /************************************************************************/
  53.  
  54. extern void    RbfClearMatrix(RbfFloatMatrix *m, double c);
  55.  
  56. /************************************************************************/
  57. /* returns the square norm of  matrix m                             */
  58. /************************************************************************/
  59.  
  60. extern float    RbfSquareOfNorm(RbfFloatMatrix *m);
  61.  
  62. /************************************************************************/
  63. /* sets m to the idempotent matrix                           */
  64. /************************************************************************/
  65.  
  66. extern void    RbfIdempotentMatrix(RbfFloatMatrix *m);
  67.  
  68. /************************************************************************/
  69. /* multiplies matrix m with a constant factor                  */
  70. /************************************************************************/
  71.  
  72. extern void    RbfMulScalarMatrix(RbfFloatMatrix *m, float a);
  73.  
  74. /************************************************************************/
  75. /* set m1 to m2 (m1 = m2). m1 must be allocated with the same        */
  76. /* dimensions as m2                            */
  77. /************************************************************************/
  78.  
  79. extern void    RbfSetMatrix(RbfFloatMatrix *m1, RbfFloatMatrix *m2);
  80.  
  81. /************************************************************************/
  82. /* set m1 to m2 transposed (m1 = m2T)                    */
  83. /* number of rows of m1 must be equal to number of columns of m2.    */
  84. /* number of columns of m1 must be equal to number of rows of m2.    */
  85. /************************************************************************/
  86.  
  87. extern void    RbfTranspMatrix(RbfFloatMatrix *m1, RbfFloatMatrix *m2);
  88.  
  89. /************************************************************************/
  90. /* set m to inverse of m (m = m^-1).                    */
  91. /* returns 0 if impossible, 1 otherwise, negative if kernel error    */
  92. /************************************************************************/
  93.  
  94. extern int    RbfInvMatrix(RbfFloatMatrix *m);
  95.  
  96. /************************************************************************/
  97. /* function RbfMulTranspMatrix:                        */
  98. /* set m1 to m2*m2T. number of rows of m2 must be equal to number of    */
  99. /* rows and columns of m1.                                              */
  100. /************************************************************************/
  101.  
  102. extern void    RbfMulTranspMatrix(RbfFloatMatrix *m1, RbfFloatMatrix *m2);
  103.  
  104. /************************************************************************/
  105. /* set m1 to m2*m3. number of columns of m2 must be equal to number of  */
  106. /* rows of m3. m1 must be allocated with r = number of rows of m2 and   */
  107. /* c = number of columns of m3.                        */
  108. /************************************************************************/
  109.  
  110. extern void    RbfMulMatrix(RbfFloatMatrix *m1, RbfFloatMatrix *m2, RbfFloatMatrix *m3); 
  111.  
  112. /************************************************************************/
  113. /* set m1 to m2+m3. number of columns of m1, m2 and m3 must be equal.    */
  114. /* number of rows of m1, m2 and m3 must be equal.            */
  115. /************************************************************************/
  116.  
  117. extern void    RbfAddMatrix(RbfFloatMatrix *m1, RbfFloatMatrix *m2, RbfFloatMatrix *m3); 
  118.  
  119. /************************************************************************/
  120. /* print out matrix m to stream (file) s                */
  121. /************************************************************************/
  122.  
  123. extern void    RbfPrintMatrix(RbfFloatMatrix *m, FILE *s);
  124.  
  125. /************************************************************************/
  126. /* print message to stderr                                    */
  127. /************************************************************************/
  128.  
  129. extern void    ErrMess(char *message);
  130.  
  131. /************************************************************************/
  132. /* macro definitions                            */
  133. /************************************************************************/
  134.  
  135. /************************************************************************/
  136. /* set element at row r and column c in matrix referenced by m to the   */
  137. /* value of v. r goes from 0 to rows -1, c goes from 0 to columns -1    */
  138. /************************************************************************/
  139.  
  140. #define    RbfMatrixSetValue(m, r, c, v)    ((m)->r_pt)[r][c] = v
  141.  
  142. /************************************************************************/
  143. /* get value of element at row r and column c in matrix referenced by m.*/
  144. /* r goes from 0 to rows -1, c goes from 0 to columns -1        */
  145. /************************************************************************/
  146.  
  147. #define RbfMatrixGetValue(m, r, c)    (((m) -> r_pt)[r][c])
  148.  
  149.  
  150.  
  151. #endif
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159. /* 141 lines generated by deleteprivatedefinitions.awk */
  160.